// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false

//路由守卫   每次发生页面跳转就会触发  
//router.beforeEach((to,from,next)=>{
//		console.log(to)
//		if(to.meta.require==true){  //页面需要登录
//			var islogin=sessionStorage.getItem("islogin")
//			if(islogin){
//				next()
//			}else{  //没有登录
//					next("/login")
//			}
//		}else{
//			next()
//		}
//})

router.beforeEach((to, from, next) => {
	console.log(to)
	if(to.meta.require==true){  //判断页面是否需要权限
			var islogin=sessionStorage.getItem("islogin")
			if(islogin!=null||islogin==false){
					next()
			}else{
				next("/login")
			}
	}else{
		 next();	
	}
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
